#include<bits/stdc++.h>
using namespace std;

const int maxn=100005,maxh=1<<29,maxl=-(1<<29);

int n,m,dct[maxn],L,V,d[maxn],v0[maxn],a[maxn],dd,ans=0;

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    int tt; cin>>tt;
    while(tt--)
    {
        ans=0;
        cin>>n>>m>>L>>V;
        for(int i=0;i<n;i++) { cin>>d[i]>>v0[i]>>a[i]; }
        for(int i=0;i<m-1;i++) cin>>dct[i];
        cin>>dd;
        for(int i=0;i<n;i++) ans+=pow(v0[i],2)+2*a[i]*(dd-d[i])>V*V;
        cout<<ans<<' '<<m-1;
    }

    return 0;
}
